package com.JavaNet.chapter7_urlConnection;

import java.io.*;
import java.net.*;
import java.util.*;

/**
 * @author harold
 *
 * 示例 7-15
 *
 * HEAD 请求方法
 *
 */
public class LastModified {


    private static String urlStr = "https://www.baidu.com";

    public static void main(String[] args) {


        try {
            URL u = new URL(urlStr);
            HttpURLConnection http = (HttpURLConnection) u.openConnection();
            http.setRequestMethod("HEAD");
            System.out.println(u + " was last modified at " + new Date(http.getLastModified()));
        } catch (MalformedURLException ex) {
            System.err.println(" is not a URL I understand");
        } catch (IOException ex) {
            System.err.println(ex.getMessage());
        }
        System.out.println();
    }


}
